<template>
	<view class="mainBg h100 container">
		<navbar title="换手机号" />
		<view class="form">
			<view class="col">
				<image src="@/static/login/form-icon1.png" mode=""></image>
				<input v-model="phone" type="tel" placeholder="请输入手机号" />
			</view>
			<view class="col">
				<image src="@/static/login/form-icon2.png" mode=""></image>
				<input v-model="code" type="text" placeholder="请输入验证码" />
				<sendCode :phone="phone" :event="event" />
			</view>
		</view>
		<view class="submit" @click="save">
			保存
		</view>
	</view>
</template>

<script>
	import sendCode from '@/components/sendCode.vue'
	export default {
		components: {
			sendCode
		},
		data() {
			return {
				phone: '',
				code: '',
				event:'change'
			}
		},
		onLoad() {

		},
		methods: {
			save() {
				this.$post("/user/updateMobile", {
					phone: this.phone,
					code: this.code
				}).then(res => {
					this.$toast(res.msg)
					if (res.code == 200) {
						setTimeout(() => {
							uni.navigateBack()
						}, 500)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #35CBAD;
	}

	.form {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 0 40rpx;
		margin-top: 50rpx;

		.col {
			display: flex;
			align-items: center;
			padding: 40rpx 0;
			border-bottom: 1px solid #eee;
			position: relative;

			image {
				width: 36rpx;
				height: 36rpx;
			}

			input {
				font-size: 28rpx;
				padding: 0 20rpx;
			}
		}
	}

	.submit {
		background: linear-gradient(180deg, rgba(130, 234, 154, 1) 0%, rgba(81, 199, 108, 1) 100%);
		text-align: center;
		border-radius: 100px;
		color: #fff;
		line-height: 82rpx;
		font-size: 32rpx;
		margin-top: 80rpx;
	}
</style>